#!/usr/bin/expect

set timeout 30
set host [lindex $argv 0]
set user [lindex $argv 1]
set pswd [lindex $argv 2]
set port [lindex $argv 3]

if {$port eq ""} {set port 22}

spawn ssh -o StrictHostKeyChecking=no -p $port $user@$host 

expect {
        "(yes/no)?"
        {send "yes\n";exp_continue;}
	      -re "(p|P)ass(word|wd):"
        {send "$pswd\n"}
}

interact
